package com.itkang.observer;

/**
 * <p>
 * 场景:
 * </p>
 *
 * @author york yuan
 * @version 1.0
 * @since 15/7/1下午2:20
 */
public class Main {

    public static void main(String[] args) {
        //声明两个观察者
        TimObserver tim = new TimObserver();
        LucyObserver lucy = new LucyObserver();
        //声明subject对象,并注册观察者
        WeatherObserver weatherObserver = new WeatherObserver();
        //注册两个观察者,并调用
        weatherObserver.addObserver(tim);
        weatherObserver.addObserver(lucy);
        weatherObserver.setChanged();
        weatherObserver.notifyObservers(new String("show tip"));
        //删除一个观察者,并调用
        weatherObserver.deleteObserver(lucy);
        weatherObserver.setChanged();
        weatherObserver.notifyObservers(new String("show tip,delete lucy"));

    }
}
